package ar.edu.itba.it.cg.grupo01.impl.shape;

import java.util.ArrayList;
import java.util.List;

import javax.vecmath.Point3f;

import ar.edu.itba.it.cg.grupo01.impl.IntersectionFactory;

public class Box extends TriangleMesh {

	List<Point3f> vertices;
	
	
	// hace caja unitaria centrada en el (0.0, 0.0, 0.0)
	public Box(IntersectionFactory intersectionFactory) {
		this(defaultBox(intersectionFactory), intersectionFactory);
	}
	
	public Box(List<Triangle> triangles, IntersectionFactory intersectionFactory) {
		super(triangles, intersectionFactory);
		// TODO Auto-generated constructor stub
	}

	private static List<Triangle> defaultBox(IntersectionFactory intersectionFactory) {
		
		List<Triangle> box = new ArrayList<Triangle>();
		
		Point3f a = new Point3f(-0.5f, -0.5f, -0.5f);
		Point3f b = new Point3f(-0.5f, +0.5f, -0.5f);
		Point3f c = new Point3f(+0.5f, +0.5f, -0.5f);
		Point3f d = new Point3f(+0.5f, -0.5f, -0.5f);
		Point3f e = new Point3f(-0.5f, -0.5f, +0.5f);
		Point3f f = new Point3f(-0.5f, +0.5f, +0.5f);
		Point3f g = new Point3f(+0.5f, +0.5f, +0.5f);
		Point3f h = new Point3f(+0.5f, -0.5f, +0.5f);
		
		box.add(new Triangle(a, b, d, intersectionFactory));
		box.add(new Triangle(b, c, d, intersectionFactory));
		box.add(new Triangle(a, b, e, intersectionFactory));
		box.add(new Triangle(b, e, f, intersectionFactory));
		box.add(new Triangle(b, c, f, intersectionFactory));
		box.add(new Triangle(c, f, g, intersectionFactory));
		box.add(new Triangle(c, d, h, intersectionFactory));
		box.add(new Triangle(c, g, h, intersectionFactory));
		box.add(new Triangle(e, f, h, intersectionFactory));
		box.add(new Triangle(f, g, h, intersectionFactory));
		box.add(new Triangle(a, d, e, intersectionFactory));
		box.add(new Triangle(e, d, h, intersectionFactory));
		
		return box;
	}
}
